<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*,app.stock.common.*,app.stock.web.*, app.stock.server.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<style type="text/css">
table {
	table-layout: fixed;
}

td {
	white-space: nowrap;
	overflow: hidden;
}
</style>
<div style="overflow: scroll; overflow-x: scroll; overflow-y: scroll;">
<table cellspacing="1" cellpadding="1" border="1">
	<tr>
		<td colspan="3"></td>
		<td colspan="6">持股数据</td>
		<td colspan="5">此轮数据</td>
		<td colspan="3">已交易数据</td>
		<td colspan="5">总数据</td>
	</tr>
	<tr>
		<td class="NoNewline"><%=Constants.label_sequence%></td>
		<td class="NoNewline"><%=Stock.codeLabel%></td>
		<td class="NoNewline"><%=Stock.nameLabel%></td>

		<td class="NoNewline"><%=Stock.currentPriceLabel%></td>
		<td class="NoNewline"><%=Stock.currentAmountLabel%></td>
		<td class="NoNewline"><%=Stock.currentMarketValueLabel%></td>
		<td class="NoNewline"><%=Stock.currentMarketValueRateLabel%></td>
		<td class="NoNewline"><%=Stock.currentInvestmentLabel%></td>
		<td class="NoNewline"><%=Stock.currentInvestmentPriceLabel%></td>

		<td class="NoNewline" onclick="sort('<%=Stock.thisInvestmentName%>');"><%=Stock.thisInvestmentLabel%></td>
		<td class="NoNewline"><%=Stock.thisInvestmentPriceLabel%></td>
		<!--td class="NoNewline"><%=Stock.thisProfitWithoutCurrentMarketValueLabel%></td-->
		<td class="NoNewline"><%=Stock.thisBaobenPriceLabel%></td>
		<td class="NoNewline" onclick="sort('<%=Stock.thisProfitName%>');"><%=Stock.thisProfitLabel%></td>
		<td class="NoNewline" onclick="sort('<%=Stock.thisProfitRateName%>');"><%=Stock.thisProfitRateLabel%></td>

		<td class="NoNewline" onclick="sort('<%=Stock.transactionedInvestmentName%>');"><%=Stock.transactionedInvestmentLabel%></td>
		<td class="NoNewline" onclick="sort('<%=Stock.transactionedProfitName%>');"><%=Stock.transactionedProfitLabel%></td>
		<td class="NoNewline" onclick="sort('<%=Stock.transactionedProfitRateName%>');"><%=Stock.transactionedProfitRateLabel%></td>

		<td class="NoNewline" onclick="sort('<%=Stock.stockInvestmentName%>');"><%=Stock.stockInvestmentLabel%></td>
		<td class="NoNewline"><%=Stock.stockProfitWithoutCurrentMarketValueLabel%></td>
		<td class="NoNewline"><%=Stock.stockBaobenPriceLabel%></td>
		<td class="NoNewline" onclick="sort('<%=Stock.stockProfitName%>');"><%=Stock.stockProfitLabel%></td>
		<td class="NoNewline" onclick="sort('<%=Stock.stockProfitRateName%>');"><%=Stock.stockProfitRateLabel%></td>
	</tr>
	<%
		List list = (List) request.getAttribute(WebConstants.key_attr_stockList);
		//request.removeAttribute(WebConstants.key_attr_stockList);
		if (list == null) {
		    StockManager mgr = new StockManager();
			Summary summary = mgr.getSummary(null);
			list = summary.stockSummaryList;
			if(request.getAttribute(WebConstants.key_attr_acct)==null){
		        request.setAttribute(WebConstants.key_attr_acct, summary.acct);
			}
		}
		int stockNum = list.size();
		for (int i = 1; i <= stockNum; i++) {
		Stock st = (Stock) list.get(i - 1);
	%>
	<tr name="tx_record" onclick="changeActiveRow(this);">
		<td><%=i%></td>
		<td><a href="StockCtrl?action=query&page=summary.jsp&<%=Transaction.codeName%>=<%=st.code%>"><%=st.code%></a></td>
		<td><%=st.name%></td>

		<td><input name="<%=Stock.currentPriceName%>" value="<%=st.currentPrice%>" style="width: 40px;"></input></td>
		<td name="<%=Stock.currentAmountName%>"><%=st.currentAmount%></td>
		<td name="<%=Stock.currentMarketValueName%>"><%=st.currentMarketValue%></td>
		<td name="<%=Stock.currentMarketValueRateName%>"><%=st.currentMarketValueRate%></td>
		<td name="<%=Stock.currentInvestmentName%>"><%=st.currentInvestment%></td>
		<td name="<%=Stock.currentInvestmentPriceName%>"><%=st.currentInvestmentPrice%></td>

		<td name="<%=Stock.thisInvestmentName%>"><%=st.thisInvestment%></td>
		<td name="<%=Stock.thisInvestmentPriceName%>"><%=st.thisInvestmentPrice%></td>
		<!--td name="<%=Stock.thisProfitWithoutCurrentMarketValueName%>"><%=st.thisProfitWithoutCurrentMarketValue%></td-->
		<td name="<%=Stock.thisBaobenPriceName%>"><%=st.thisBaobenPrice%></td>
		<td name="<%=Stock.thisProfitName%>"><%=st.thisProfit%></td>
		<td name="<%=Stock.thisProfitRateName%>"><%=st.thisProfitRate%></td>

		<td name="<%=Stock.transactionedInvestmentName%>"><%=st.transactionedInvestment%></td>
		<td name="<%=Stock.transactionedProfitName%>"><%=st.transactionedProfit%></td>
		<td name="<%=Stock.transactionedProfitRateName%>"><%=st.transactionedProfitRate%></td>

		<td name="<%=Stock.stockInvestmentName%>"><%=st.stockInvestment%></td>
		<td name="<%=Stock.stockProfitWithoutCurrentMarketValueName%>"><%=st.stockProfitWithoutCurrentMarketValue%></td>
		<td name="<%=Stock.stockBaobenPriceName%>"><%=st.stockBaobenPrice%></td>
		<td name="<%=Stock.stockProfitName%>"><%=st.stockProfit%></td>
		<td name="<%=Stock.stockProfitRateName%>"><%=st.stockProfitRate%></td>
	</tr>
	<%
		}
	%>
</table>
</div>
<script type="text/javascript">
	var elemNames = ['<%=Stock.currentMarketValueName%>',
	                 '<%=Stock.currentInvestmentName%>',
	                 '<%=Stock.currentInvestmentPriceName%>',
	                 '<%=Stock.thisProfitWithoutCurrentMarketValueName%>',
	                 '<%=Stock.thisBaobenPriceName%>',
	                 '<%=Stock.thisInvestmentName%>',
	                 '<%=Stock.thisInvestmentPriceName%>',
	                 '<%=Stock.thisProfitName%>',
	                 '<%=Stock.transactionedProfitWithoutCurrentMarketValueName%>',
	                 '<%=Stock.transactionedBaobenPriceName%>',
	                 '<%=Stock.transactionedInvestmentName%>',
	                 '<%=Stock.transactionedProfitName%>',
	                 '<%=Stock.stockProfitWithoutCurrentMarketValueName%>',
	                 '<%=Stock.stockBaobenPriceName%>',
	                 '<%=Stock.stockInvestmentName%>',
	                 '<%=Stock.stockProfitName%>'];
	toFixedFloatByName(elemNames,'td');
	elemNames = ['<%=Stock.currentMarketValueRateName%>',
	             '<%=Stock.thisProfitRateName%>',
	             '<%=Stock.transactionedProfitRateName%>',
	             '<%=Stock.stockProfitRateName%>'];
	toFixedPercentageByName(elemNames,'td'); 
	function sort(columnName){
		submitForm('query_form',['page=summary.jsp','action=sort','columnName='+columnName]);
	};
	var currentActiveRow; 
	function changeActiveRow(obj) { 
		if(currentActiveRow) currentActiveRow.style.backgroundColor=''; 
		currentActiveRow=obj; 
		currentActiveRow.style.backgroundColor='Orange'; 
	};
</script>